<%= render partial: 'shipit/repositories/header', locals: { repository: @repository } %>

<div class="wrapper">
  <section>
    <header class="section-header">
      <h2>Settings (Repository <%= @repository.github_repo_name %>)</h2>
    </header>

    <div class="setting-section">
      <%= form_for @repository do |f| %>
        <div class="field-wrapper">
          <%= f.check_box :review_stacks_enabled %>
          <%= f.label :review_stacks_enabled, "Dynamically provision stacks for Pull Requests?" %>
        </div>

        <div class="field-wrapper">
          <p>
            <%= f.label :provisioning_behavior, "Provisioning behavior", aria: { describedby: 'provisioningBehaviorHelp' } %>
            <%= f.select :provisioning_behavior, Shipit::Repository.provisioning_behaviors.map { |key, value| [ key.titleize, key] } %>
          </p>
          <p>
            <small class="form-text text-muted" id="provisioningBehaviorHelp">
              When "Allow All", the provisioning label has no effect on dynamic stack provisioning - ALL Pull Requests dynamically provision stacks.
            </small>
          </p>
          <p>
            <small class="form-text text-muted">
              When "Allow With Label", dynamic provisioning occurs ONLY for Pull Requests whose labels include the 'Provisioning Label'.
            </small>
          </p>
          <p>
            <small class="form-text text-muted">
              When "Prevent With Label", dynamic provisioning will occur for every Pull Request EXCEPT those whose labels include the 'Provisioning Label'.
            </small>
          </p>
        </div>

        <div class="field-wrapper">
          <%= f.label :provisioning_label_name, "Provisioning label" %>
          <%= f.text_field :provisioning_label_name %>
        </div>

        <%= f.submit class: "btn", value: "Save" %>
      <% end %>
    </div>

    <div class="setting-section">
      <h5>Delete this repository</h5>
      <p>This action will delete the repository and its stacks from Ship it permanently. Be careful.</p>
      <%= button_to "Delete…", repository_path(@repository), class: 'btn btn--delete', data: {confirm: 'Are you sure?'}, method: :delete %>
    </div>
  </section>
</div>
